package com.mall.order.services;

import com.mall.order.StockService;
import com.mall.order.dal.entitys.Stock;
import com.mall.order.dal.persistence.StockMapper;
import org.apache.dubbo.config.annotation.Service;
import org.springframework.beans.factory.annotation.Autowired;
import tk.mybatis.mapper.entity.Example;

/**
 * @Author: lin
 * @Date: 2020/7/13 14:20
 */

@Service
public class StockServiceImpl implements StockService {

    @Autowired
    StockMapper stockMapper;


    @Override
    public Boolean isEnough(Integer productId, Integer productNum) {
        Stock stock = stockMapper.selectByPrimaryKey(productId);
        if (stock == null){
            return false;
        }
        int count = stock.getStockCount().intValue();
        int num = productNum;
        if (count < num){
            return false;
        }
        return true;
    }
}
